/*
 * Copyright (c) 2006, 2023, webrx.cn All rights reserved.
 *
 */
package cn.webrx;


import java.util.Date;

/**
 * <p>Project: jse2306 - Date1</p>
 * <p>Powered by webrx On 2023-10-10 17:41:02</p>
 * <p>description: </p>
 *
 * @author 李四 [webrx@126.com]
 * @version 1.0
 * @since 17
 */
public class Date1 {
    public static void main(String[] args) {
        Date d = new Date();

        //获取时间戳（long数字）
        long t1 = d.getTime();
        System.out.println(t1);

        int year = d.getYear() + 1900;
        System.out.println(year);

        int month = d.getMonth() + 1;
        System.out.println(month);

        int date = d.getDate();//
        System.out.println(date);

        int day = d.getDay(); //0 - 6
        System.out.println(day);

        if (day == 0) System.out.println("星期日");
        if (day == 1) System.out.println("星期一");
        if (day == 2) System.out.println("星期二");
        if (day == 3) System.out.println("星期三");
        if (day == 4) System.out.println("星期四");
        if (day == 5) System.out.println("星期五");
        if (day == 6) System.out.println("星期六");


        long t2 = System.currentTimeMillis();
        System.out.println(t2);

        //输出年月日时分秒 格式化输出
        System.out.printf("%tF %tT%n", d, d);
        System.out.printf("%d年%d月%d日 %d:%d:%d%n", year, month, date, d.getHours(), d.getMinutes(), d.getSeconds());

    }
}
